Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(bunotel): Ability to override span names #1120

Merged
merged 1 commit into from
Feb 10, 2025

Conversation

NathanBaulch
Copy link
Contributor

@NathanBaulch NathanBaulch commented Feb 8, 2025

Bun OTEL spans would be much more informative in APM tools if their name included the primary table being queried. This could be added easily enough, however it might be nice to follow the convention used in other popular middlewares like otelhttp by adding a WithSpanNameFormatter option.

This PR allows me to add the primary query table to span names like so:

bunotel.NewQueryHook(bunotel.WithSpanNameFormatter(func(event *bun.QueryEvent) string {
	name := event.Operation()
	if event.IQuery != nil {
		if tableName := event.IQuery.GetTableName(); tableName != "" {
			name += " " + tableName
		}
	}
	return name
}))

@j2gg0s j2gg0s merged commit 41abcd3 into uptrace:master Feb 10, 2025
4 checks passed
@NathanBaulch NathanBaulch deleted the trace-span-name branch February 10, 2025 03:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants